package com.hopu.mybatis.controller;

import com.hopu.mybatis.entity.TbBook;
import com.hopu.mybatis.service.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("book")
public class BookController {

    @Autowired
    private IBookService bookService;

    @RequestMapping("list")
    public String list(Model model){
        List<TbBook> tbBooks = bookService.selectAll();
        model.addAttribute("books",tbBooks);
        return "book_list";
    }
}
